package{
	import down.Downing;
	import down.DownRegAssets;
	import down.TestSocket;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;
	import flash.utils.ByteArray;
	import minglu.MingLu;
	import morn.core.handlers.Handler;
	import testRole.TestRole;
	import web.TestList;
	import web.WebResAssets;
	import web.WebSpeed;
	/**
	 * ...
	 * @author ...
	 */
	public class Main extends Sprite {
		
		private var menu:ContextMenu=new ContextMenu();
		private static var stage:Stage;
		private var loader:Loader
		public function Main() 
		{
			this.menu.hideBuiltInItems();
			this.menu.customItems.push(new ContextMenuItem("down.1.0.0.2"));
			this.contextMenu=menu;
			Main.stage=this.stage;
			//初始化组件
			App.init(this);
			//new MingLu();
			new DownRegAssets(new Handler(this.start));
			//new WebResAssets(new Handler(this.start));
			//TestRole.instance.start();
		}
		private function start():void{
			Downing.instance.start();
			//new TestSocket();
			//WebSpeed.instance.start();
		}
		
		private static var debugText:TextField=new TextField();
		public static function traces(...args):void{
			if(!debugText.border){
				debugText.alpha=.7;
				debugText.width=300;
				debugText.height=400;
				debugText.border=true;
				debugText.wordWrap=true;
				debugText.multiline=true;
				debugText.background=true;
				debugText.backgroundColor=0xffffff;
				debugText.type=TextFieldType.INPUT;
				debugText.defaultTextFormat=new TextFormat("宋体",12,0);
			}
			for(var i:int=0;i<args.length;i++){
				args[i]=JSON.stringify(args[i]);
			}
			debugText.appendText(args.join(",")+"\n");
			debugText.scrollV=debugText.numLines;
			Main.stage.addChild(debugText);
		}
	}

}